<?php
//用于计算一个数组中元素去掉最大和最小数的平均数
    class s{
    	public $a;

    	public function x(){
    		$a = $this->a;
    		$sum = 0;
    		$ave = 0;
    		$n = count($a);

    		$max = $a[0];
    		$min = $a[0];

    		for($i = 0;$i < $n;$i++){
    			if($a[$i] > $max)
    				$max = $a[$i];
    			 if($a[$i] < $min)
    			 	$min = $a[$i];
    			 $sum = $sum + $a[$i];

    		}
    		$ave = ($sum - $max - $min)/($n-2);
    		echo "$ave";
    }
}

    $c1 = new s();
    $c1->a = array(9,3,5,4,8,7,6,2);
    $c1->x();
    ?>




   